#include <stdio.h>
#include <stdlib.h>
#include <pic18f6722.h>


#define uint unsigned int
#define uchar unsigned char

#define Work_LED  RB5

void Device_Indicator_Initialize(unsigned char Status);
void Device_Indicator_SetBatteryLED(uchar BatteryState);
void Device_Indicator_SetCountLED(uchar CountState);
void Device_Indicator_SetDirectorLED(uchar Dir, uchar Mode);
void Device_Indicator_SetDistanceLED(uchar BatteryState);
void Device_Indicator_SetLED(uchar SetLED);

#define BATTERY_RED_LED    RG1   //RED1
#define BATTERY_GREEN_LED  RG0   //GREEN1

#define COUNT_RED_LED      RE1   //RED2
#define COUNT_GREEN_LED    RE0   //GREEN2

#define FORWARD_LED        RA3   //FORWARD LED
#define BACK_LED           RF0   //BACK LED

#define LENGTH_LED0        RD2   //SEG_LED0
#define LENGTH_LED1        RD1   //SEG_LED1
#define LENGTH_LED2        RD0   //SEG_LED2
#define LENGTH_LED3        RA0   //SEG_LED3
#define LENGTH_LED4        RE7   //SEG_LED4

#define ALL_OFF            0
#define FORWARD            1
#define BACK               2
#define ALL_ON             3
#define STATIC_DISPLAY     0 
#define FLASH_DISPLAY      1

#define RED_LED            RF2   //RED1
#define GREEN_LED          RC2   //GREEN1
#define KEY_IS_DOWM        RC7

//*********************************************************************
/* Initialize Indicator
 * input void 
 * return: void
 * author: Guichuan.He
 * date: 2016-9-28
*/
//**********************************************************************
void Device_Indicator_Initialize(unsigned char Status)
{
   Device_Indicator_SetLED(0);
   
}

void set_red_led(unsigned char led)
{
    if(led==1)
    {
      RED_LED=1;  
    }
    else
    {
       RED_LED=0;
    }
}
void set_green_led(unsigned char led)
{
    if(led==1)
    {
        GREEN_LED=1;
    }
    else
    {
      GREEN_LED=0;  
    }
}

void set_yellow_led(unsigned char led)
{
    if(led==1)
    {
        GREEN_LED=1;
        RED_LED=1;
    }
    else
    {
        GREEN_LED=0;
        RED_LED=0; 
    }
}
void Device_Indicator_SetLED(uchar SetLED)
{
    switch(SetLED)
    {
        case 0:   // dark
            RED_LED   = 0;   
            GREEN_LED = 0;   
            break;
        case 1:   //red
            RED_LED   = 1;   
            GREEN_LED = 0; 
            break;
        case 2:  //green
            RED_LED   = 0;   
            GREEN_LED = 1; 
            break;
        case 3:  //yellow
            GREEN_LED = 1; 
            RED_LED   = 1;   
            break;
        case 4:  //flash
            RED_LED   = ~ RED_LED;
            GREEN_LED = ~ GREEN_LED;
            break;
        case 5:
            RED_LED   = 0;
            GREEN_LED = ~ GREEN_LED;
            break; 
        default:
            RED_LED   = 0;   
            GREEN_LED = 0; 
            break;
    }
}





















void Device_Indicator_SetBatteryLED(uchar BatteryState)
{
   
}
void Device_Indicator_SetCountLED(uchar CountState)
{
}
void Device_Indicator_SetDirectorLED(uchar Dir, uchar Mode)
{ 
}


void Device_Indicator_SetDistanceLED(uchar Distance)
{
 
}

